package lambda_expression.jdk;

import java.util.Arrays;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * Function
 * 接收参数T，返回结果对象R
 */
public class FunctionTest {
    public static void main(String[] args) {
        Function<String, Boolean> func = (String name) -> {
            return name.equals("admin");
        };

        System.out.println(func.apply("admin"));
        System.out.println(func.apply("user"));
        System.out.println(functionTest());
    }

    /**
     * result: this=is=a=test
     * @return
     */
    private static String functionTest() {
        String[] result = "this is a test".split("\\s");
        return Arrays.stream(result).map(v -> v).collect(Collectors.joining("="));
    }
}
